import { Component } from '@angular/core';
import { Student } from './model/student';
import { StudentService } from './service/student.service';
import { Studentvo } from './vo/studentvo';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'angular';
//变量类型声明
  textvalue:string;
  numbervalue:number;
  student:Student;
  studentvo:Studentvo


  constructor(private studentservice:StudentService){

  }



//初始化方法
ngOnInit() {
//变量的初始化
this.textvalue='今天天气很好';
this.numbervalue=58+76;
this.studentvo=new Studentvo();
this.student=new Student();
//this.student.name="测试姓名"
 //this.student.sex="女";
 //this.student.stunum="201621447238";
//this.student.birthday=new Date().getTime();
//this.student.nativeplace="测试籍贯";
this.studentservice.getAnObject()
    .then((data:any)=>{
   this.student=data;
    })


}
//保存方法
  add(){
    console.dir(this.studentvo);
    this.studentservice.addStudentinfo(this.studentvo)
    .then((data:any)=>{
  //请求时间完成后
  this.studentservice.getAnObject()
  .then((data:any)=>{
 this.student=data;
  })

       })

  }

}
